//
// 
//  柳州微博
//
//  Created by Apple_Lzzy40 on 16/10/12.
//  Copyright © 2016年 Apple_Lzzy40. All rights reserved.
//

#import "ZQTilteButton.h"

@implementation ZQTilteButton
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //常态图片
        UIImage *image=[UIImage imageNamed:@"navigationbar_arrow_down"];
        [self setImage:image forState:UIControlStateNormal];
        [self setImage:[UIImage imageNamed:@"navigationbar_arrow_up"] forState:UIControlStateSelected];
        

        

    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    //1.把titleLabel  x坐标进行调整，与imageView的X最左坐标一致
   // self.titleLabel.x=self.imageView.x;
    self.titleLabel.x=0;
    
    //2.把imageView  X坐标进行调整，与titleLabel的X最右坐标一致
    self.imageView.x=CGRectGetMaxX(self.titleLabel.frame);
}
-(void)setTitle:(NSString *)title forState:(UIControlState)state
{
    [super setTitle:title forState:state];
    //自适应尺寸
    [self sizeToFit];
}
-(void)setImage:(UIImage *)image forState:(UIControlState)state
{
    [super setImage:image forState:state];
    //自适应尺寸
    [self sizeToFit];
}

@end
